home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / fido / XPACK275.lha / rexx / XFLO.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-17  |  5KB  |  111 lines

  1. /**/q_outs=1
  2. v="$VER: XFLO Rexx  XFERQ Mail Handler Williamson 55.13"
  3. options results;options failat 99
  4. Parse upper arg OUTDIR hostaddress ADDRESS_LIST
  5. if words(ADDRESS_LIST)>1 then hold_address=word(ADDRESS_LIST,1);else hold_address=ADDRESS_LIST
  6. XFQ_SITE_OBJECT=XfqGetAddress(hold_address)
  7. if XfqSessionUp(XFQ_SITE_OBJECT) then do  
  8.  if ~XfqHoldMailer(XFQ_SITE_OBJECT) then do
  9.   Say 'HOLD Failed:'XFQERRORMSG hold_address
  10.   drop XFQERRORCODE XFQERRORMSG;call XfqDropObject(XFQ_SITE_OBJECT);call XfqClose();exit
  11.  end
  12. end;else do
  13.  Say 'Site 'hold_address' not online, exiting'
  14.  drop XFQERRORCODE XFQERRORMSG;call XfqDropObject(XFQ_SITE_OBJECT);call XfqClose();exit
  15. end
  16. ADDRESS_LIST=strip(ADDRESS_LIST)
  17. XQ_NOTHING=20;XQ_DELETE=21;XQ_TRUNCATE=22;xpri.H=0;xpri.C=50;xpri.D=30;xpri.N=0;xpri.F=0;xpri.O=0
  18. log=show('p','ROOFLOG');call putlog(ADDRESS_LIST)
  19. id=pragma('ID')
  20. do ai=1 to words(ADDRESS_LIST)
  21.  REMOTE_ADDRESS=word(ADDRESS_LIST,ai)
  22.  parse var REMOTE_ADDRESS rad "#" raz ":" ran "/" raf "." rap
  23.  call sendflos;call sendouts
  24. end
  25. cleanup:
  26. call XfqReleaseMailer(XFQ_SITE_OBJECT);call XfqDropObject(XFQ_SITE_OBJECT)
  27. call XfqClose();call delete('T:flo'id);call delete('T:out'id)
  28. exit 0
  29. SENDOUTS:
  30. Address COMMAND 'LIST >T:out'id OUTDIR||raz'.'ran'.'raf'.'rap'.?UT quick nohead'
  31. if word(statef("T:out"id),2)=0 then do;call PutLog('No 4D ?UT files in 'OUTDIR' for 'REMOTE_ADDRESS);return;end
  32. if ~open('outs',"T:out"id,'R') then do;call PutLog("Error opening 4D .?UT list");return;end
  33. do while ~eof('outs')
  34.  outfile=upper(readln('outs'));if outfile="" then iterate
  35.  parse var outfile x '.' x '.' x '.' x '.' ext;drop x
  36.  if ~q_outs & ext="OUT" then do;call PutLog('Skipping Unarchived echomail:'outfile);Iterate;end
  37.  xtype=left(ext,1);if pos(xtype,'H C D N O')>0 then priority=xpri.xtype
  38.  else do;call PutLog('ERROR: cannot queue 'outfile);Iterate;end
  39.  file=OUTDIR||outfile;sendas=left(date(),2)||compress(time(),":")||".PKT"
  40.  flags=XQ_DELETE
  41.  QUERY.XQ_NAME=file;QUERY.XQ_SITE=XFQ_SITE_OBJECT
  42.  work=NULL;work=XfqFindWork(QUERY)
  43.  if work=NULL then do;call PutLog('Sending:'file' as 'sendas' for:'REMOTE_ADDRESS' Disp:'flags' Pri:'priority)
  44.   call XfqAddWorkQuick(REMOTE_ADDRESS,file,sendas,priority,flags)
  45.  end;else call XfqUnlockWork(work)
  46.  if work~=NULL then call XfqDropObject(work)
  47. end  
  48. call close('outs')
  49. return
  50. SENDFLOS:
  51. Address COMMAND 'LIST >T:flo'id OUTDIR||raz'.'ran'.'raf'.'rap'.?LO quick nohead'
  52. if word(statef("T:flo"id),2)=0 then do;call PutLog('No 4D ?LO files in 'OUTDIR' for 'REMOTE_ADDRESS);return;end
  53. if ~open('flolist',"T:flo"id,'R') then do;call PutLog("Error opening 4D .FLO listing");return;end
  54. i=0
  55. do while ~eof('flolist')
  56.  Line=Upper(strip(space(ReadLn('flolist'),1),'B'));if Line="" then iterate
  57.  i=i+1;flofile.i=Line
  58.  parse var Line flonode.i.zone"."flonode.i.net"."flonode.i.node"."flonode.i.point"."junk
  59.  flofileadr.i=RAD'#'flonode.i.zone":"flonode.i.net"/"flonode.i.node"."flonode.i.point
  60.  ftype=left(junk,1);if pos(ftype,'H C D N F')>0 then flofile.i.pri=xpri.ftype
  61.  else do;call PutLog('Skipping Unknown FLO file:'flofile.i);i=i-1;iterate;end
  62. end
  63. call close('flolist')
  64. if i=0 then do;call PutLog("Error: No Sendable 4D ?LO Files");return;end
  65. flofile.numnodes=i
  66. do anode=1 until anode=flofile.numnodes;err=0
  67.  call PutLog("Converting" flofile.anode "for" flofileadr.anode)
  68.  floname=upper(OUTDIR||flofile.anode)
  69.  if ~exists(floname) then do;call PutLog("Error: Can't find "floname);err=1;end
  70.  else if ~Open('flofile',floname,'R') then do;call PutLog("Error: Can't open" floname);err=1;end
  71.  if ~err then do
  72.   do while ~eof('flofile')
  73.    Line=upper(ReadLn('flofile'));if Line="" then Iterate
  74.    flags=XQ_NOTHING
  75.    disp=left(Line,1);if disp="#" then do;flags=XQ_TRUNCATE;Line=delstr(Line,1,1);end
  76.    else if disp="^"|disp="-" then do;flags=XQ_DELETE;Line=delstr(Line,1,1);end
  77.    else if disp="@" then do;flags=XQ_NOTHING;Line=delstr(Line,1,1);end
  78.    if ~exists(Line) then do;call PutLog("File "Line" No Longer Exists");Iterate;end
  79.    parse var Line x '.' x '.' x '.' x '.' ext;drop x
  80.    if ext="" then do
  81.     if right(Line,3)="TIC" then flags=XQ_DELETE;else flags=XQ_NOTHING
  82.     sendas=get_fn(Line);priority=flofile.anode.pri
  83.    end;else do
  84.     tmpext=upper(left(ext,2))
  85.     if datatype(right(ext,1),'n')&(tmpext="MO"|tmpext="TU"|tmpext="WE"|tmpext="TH"|tmpext="FR"|tmpext="SA"|tmpext="SU") then do
  86.      parse var hostaddress myaddress.domain "#" myaddress.zone ":" myaddress.net "/" myaddress.node "." myaddress.point
  87.      sendas=UPPER(d2x(65536+myaddress.net-flonode.anode.net,4)||d2x(65536+myaddress.node-flonode.anode.node,4)||'.'ext)
  88.      flags=XQ_DELETE;priority=flofile.anode.pri
  89.     end;else do
  90.      sendas=get_fn(line);flags=XQ_NOTHING;priority=flofile.anode.pri
  91.     end
  92.    end;drop ext
  93.    QUERY.XQ_NAME=Line;QUERY.XQ_SITE=XFQ_SITE_OBJECT
  94.    work=NULL;work=XfqFindWork(QUERY)
  95.    if work=NULL then do;call PutLog('Sending:'Line' as 'sendas' for 'REMOTE_ADDRESS' Disp:'flags' Pri:'priority)
  96.     call XfqAddWorkQuick(REMOTE_ADDRESS,Line,sendas,priority,flags)
  97.    end;else call XfqUnlockWork(work)
  98.   end
  99.   call close('flofile');call delete(floname)
  100.  end
  101.  if work~=NULL then call XfqDropObject(work)
  102. end
  103. return
  104. get_fn: procedure
  105. if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1)
  106. else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1)
  107. else return arg(1)
  108. PutLog: procedure expose log
  109. if log then address 'ROOFLOG' 'LOGLINE' left(time(),5) 'XFLO: 'arg(1);else say arg(1)
  110. return 0
  111.